

package cn.shengchao.examstar.pay.utils.pay;

public enum PayTypeEnum {
    //
    H5_WECHAT("1", "H5微信", new WechatH5Pay()),
    XCX_WECHAT("2", "微信小程序", new WechatXcxPay());

    private String name;
    private String code;
    private PayTypeBase payType;

    PayTypeEnum(String code, String name, PayTypeBase payTypeBase) {
        this.code = code;
        this.name = name;
        this.payType = payTypeBase;
    }

    public PayTypeBase getPayType() {
        return payType;
    }

    public String getName() {
        return name;
    }

    public String getCode() {
        return code;
    }

    public static PayTypeEnum getByCode(String code) {
        for (PayTypeEnum bestPayTypeEnum : PayTypeEnum.values()) {
            if (bestPayTypeEnum.getCode().equals(code)) {
                return bestPayTypeEnum;
            }
        }
        return XCX_WECHAT;
    }
}
